package com.mall.malllibrary.global

import android.app.Application
import android.content.Context
import com.blankj.utilcode.util.Utils
import com.mall.malllibrary.util.storage.MemoryStorage

// 统一的单利类对象，可以想类一样访问属性与方法
object Mall {

    // 配置对象
    val configurator:Configurator
        get() = Configurator.instance


    fun init(context: Context): Configurator{
        val appContext = context.applicationContext
        MemoryStorage
            .instance
            .addData(GlobalKeys.APPLICATION_CONTENT, context.applicationContext)
        Utils.init(appContext as Application?)
        return Configurator.instance
    }

    fun <T> getConfiguration(key:String): T{
        return configurator.getConfigureation(key)
    }

    fun <T>getConfiguration(key:Enum<*>):T{
        return getConfiguration(key.name)
    }
}